/*************************************************************************
	> File Name: P1795.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-03-17 10:47:22
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

#define MAX_N 1000000000

unordered_map<int, bool> flag;

void init_tabel() {
    flag[1] = 1, flag[2] = 1;
    int i = 2, step = 1;
    while (i + step + 1 <= MAX_N) {
        flag[i + step + 1] = 1;
        i += step + 1;
        step++;
    }
    return ;
}

int main() {
    init_tabel();
    int n;
    cin >> n;
    while (n--) {
        int ind;
        scanf("%d", &ind);
        printf("%d\n", flag[ind]);
    }
    return 0;
}
